<template>
  <div>
    <!-- 搜索栏 -->
    <Row style="margin-top:20px">
      <Card>
        <div style="margin-top: 6px">
          <Form ref="searchData" :model="searchData" :label-width="80">
            <Row>
              <i-col :xs="24" :md="12" :lg="6">
                <FormItem label="考核类别">
                  <Input
                    placeholder="请输入考核类别"
                    v-model="searchData.assessmentType"
                    style="width: auto"
                  >
                    <Icon type="ios-search" slot="suffix"/>
                  </Input>
                </FormItem>
              </i-col>
              <i-col :xs="24" :md="12" :lg="6">
                <FormItem label="考核者">
                  <Input
                    placeholder="请输入考核者"
                    v-model="searchData.checkObject"
                    style="width: auto"
                  >
                    <Icon type="ios-search" slot="suffix"/>
                  </Input>
                </FormItem>
              </i-col>
              <i-col :xs="24" :md="12" :lg="6">
                <FormItem label="分数">
                  <Input placeholder="请输入分数" v-model="searchData.score" style="width: auto">
                    <Icon type="ios-search" slot="suffix"/>
                  </Input>
                </FormItem>
              </i-col>
            </Row>
            <Row>
              <i-col :xs="24" :md="12" :lg="6">
                <FormItem label="考核任务单号">
                  <Input
                    placeholder="请输入考核任务单号"
                    v-model="searchData.assessmentOrder"
                    style="width: auto"
                  >
                    <Icon type="ios-search" slot="suffix"/>
                  </Input>
                </FormItem>
              </i-col>
              <i-col :xs="24" :md="12" :lg="6">
                <FormItem label="考核内容">
                  <Input
                    placeholder="请输入考核内容"
                    v-model="searchData.assessmentContent"
                    style="width: auto"
                  >
                    <Icon type="ios-search" slot="suffix"/>
                  </Input>
                </FormItem>
              </i-col>
              <i-col :xs="24" :md="12" :lg="6">
                <FormItem label="考核任务名">
                  <Input
                    placeholder="请输入考核任务名"
                    v-model="searchData.assessmentTask"
                    style="width: auto"
                  >
                    <Icon type="ios-search" slot="suffix"/>
                  </Input>
                </FormItem>
              </i-col>
            </Row>
              <Row>
              <i-col :xs="24" :md="12" :lg="6">
                <FormItem label="考核来源">
                  <Input
                    placeholder="请输入考核来源"
                    v-model="searchData.assessmentSource"
                    style="width: auto"
                  >
                    <Icon type="ios-search" slot="suffix"/>
                  </Input>
                </FormItem>
              </i-col>
            </Row>
            <FormItem>
              <Button type="primary" v-if="btnAccess.query"  @click="searchSubmit(10,1)">提交搜索</Button>
              <Button@click="seachReset('searchData')" style="margin-left: 8px">重置搜索</Button>
            </FormItem>
          </Form>
        </div>
      </Card>
    </Row>
    <Row style="margin-top:20px">
      <Card>
        <Table  border :loading="tabelLoading" ref="selection" :columns="columns4" :data="data1"  height="500"></Table>
        <div style="margin-top:20px;margin-left:35%">
          <template>
            <Page
             @on-change="pageNumberChange"
             @on-page-size-change="pageSizeChange"
             :page-size="pageSize"
             :total="pageTotal"
             show-elevator
             show-sizer/>
          </template>
        </div>
      </Card>
    </Row>
  </div>
</template>

<script>
import { hasOneOf } from "@/libs/tools";
import { importantWorkAjax } from "@/api/importantAnnua";
// 查询URL
const QUERY_URL = "/gradePoint/query";

export default {
  data() {
    return {
      // 增删改查权限按钮
      btnAccess: {
        add: true,
        add2: "inline-block",
        del: "inline-block",
        upd: true,
        query: true
      },
      tabelLoading: false, // 表格loading
      searchData: {
        // 搜索数据
        assessmentType: "", // 考核类别
        checkObject: "", // 考核人
        score: "", // 分数
        assessmentOrder: "", // 考核任务单号
        assessmentContent: "", // 考核内容
        assessmentTask: "", // 考核任务名
        assessmentSource: ""// 考核来源
      },
      pageTotal: 10, // 总页数
      pageSize: 10, // 每页条数
      pageNumber: 1, // 默认第一页
      columns4: [
        {
          title: "考核类别",
          key: "assessmentType"
        },
        {
          title: "考核者",
          key: "checkObject"
        },
        {
          title: "分数",
          key: "score"
        },
        {
          title: "考核任务",
          key: "assessmentTask"
        },
        {
          title: "考核任务单号",
          key: "assessmentOrder"
        },
        {
          title: "考核内容",
          key: "assessmentContent"
        },
        {
          title: "考核来源",
          key: "assessmentSource"
        }

      ],
      data1: []// 表格数据
    };
  },
  methods: {
    // 搜索
    searchSubmit(pageSize, pageNumber) {
      this._getUserData(this.searchData, QUERY_URL, pageSize, pageNumber);
    },
    // 重置搜索
    seachReset(name) {
      this.searchData = {
        assessmentType: "", // 考核类别
        checkObject: "", // 考核人
        score: "", // 分数
        assessmentOrder: "", // 考核任务单号
        assessmentContent: "", // 考核内容
        assessmentTask: "", // 考核任务名
        assessmentSource: ""// 考核来源
      };
    },
    // 查询
    _getUserData(formData, url, pageSize, pageNumber) {
      this.tabelLoading = true;
      formData = Object.assign(formData, {
        pageSize,
        pageNumber
      });
      const keyOne = "gradePointFilter";// 注意：keyOne需要和后端接收的参数名一样
      importantWorkAjax({ formData, url, keyOne })
        .then(result => {
          // this.tabelLoading = false;
          if (result.data.code === "200") {
            this.tabelLoading = false;
            this.data1 = result.data.results.list;
            this.pageTotal = result.data.results.pageTotal;
            this.$Message.success("查询成功");
          } else {
            this.$Message.error("查询失败");
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    // 页码
    pageNumberChange(pageNumber) {
      this.pageNumber = pageNumber;
      this._getUserData(
        this.searchData,
        QUERY_URL,
        this.pageSize,
        this.pageNumber
      );
    },
    // 页数
    pageSizeChange(pageSize) {
      this.pageSize = pageSize;
      this._getUserData(
        this.searchData,
        QUERY_URL,
        this.pageSize,
        this.pageNumber
      );
    }
  },
  created() {
    this._getUserData(
      this.searchData,
      QUERY_URL,
      this.pageSize,
      this.pageNumber
    );
    // 获取按钮权限
    let btnAccess = sessionStorage.getItem("btnaccess");

    this.globalFunction(btnAccess);
  }
};

</script>
